#include<iostream>
using namespace std;
string a, b;
int main()
{
	cin >> a >> b;
	bool flag = 0;
	string s1, s2;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == '.') {
			s1 = a.substr(i + 1, a.size() - i);
			break;
		}
	}
	for (int i = 0; i < b.size(); i++) {
		if (b[i] == '.') {
			s2 = b.substr(i + 1, b.size() - i);
			break;
		}
	}
	//cout << s1 << " " << s2 << endl;
	cout << (s1 == s2 ? "YES" : "NO" )<< endl;
	return 0;
}